package com.yanqu.road.logic.activity.foxcard.game.sorcery;

import com.yanqu.road.entity.activity.foxcard.FoxEffectCard;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardGameLogic;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardShowInfo;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardShowType;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardTriggerType;
import com.yanqu.road.utils.RandomHelper;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 增加负片的效果随机到当前已拥有的小丑牌上。
 */
public class FoxCardSorceryUse8 extends FoxCardSorceryUseBase{
    @Override
    protected boolean sorceryUse(FoxCardGameLogic gameLogic) {
        int versionEffect = sorceryConfig.getParamList().get(0);


        List<FoxEffectCard> findCards = new ArrayList<>();
        gameLogic.getGameData().getEffectCards().stream().filter(card -> card.getVersionEffect() == 0).forEach(findCards::add);
        if (findCards.isEmpty()) {
            return false;
        }

        FoxEffectCard effectCard = RandomHelper.getRandomList(findCards, 1).get(0);
        effectCard.setVersionEffect(versionEffect);
        gameLogic.dealEffectCardBuff(effectCard, eFoxCardTriggerType.ADD);

        FoxCardShowInfo showInfo = gameLogic.newFoxShow(eFoxCardShowType.VERSION_EFFECT.getValue());
        showInfo.setTriggerCards(Collections.singletonList(effectCard));
        showInfo.setShowValue(versionEffect);
        return true;
    }
}
